﻿using System;
using BITS.PreCompiler.CSharp.Syntax;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BITS.PreCompiler.CSharp.Tests.Syntax
{
    using Enum = CSharp.Syntax.Enum;

    [TestClass]
    public class TestEnum : TestBase
    {
        [TestMethod]
        public void Create_Enum()
        {
            var @enum = new Enum(@identifier: "MY_ENUM",
                @modifier: Modifier.Public);

            var expectet = Comparer.Create_Enum();
            var actual   = @enum.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }

        [TestMethod]
        public void Create_Enum_With_Base()
        {
            var @enum = new Enum(@identifier: "MY_ENUM",
                @modifier: Modifier.Public).WithBase("short");

            var expectet = Comparer.Create_Enum_With_Base();
            var actual   = @enum.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }

        [TestMethod]
        public void Create_Enum_With_Members()
        {
            var @enum = new Enum(@identifier: "MY_ENUM",
                    @modifier: Modifier.Public)
                {
                    new Enum.Field(@identifier: "One")
                };

            var expectet = Comparer.Create_Enum_With_Members();
            var actual   = @enum.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }

        [TestMethod]
        public void Create_Enum_With_Members_And_Values()
        {
            var @enum = new Enum(@identifier: "MY_ENUM",
                    @modifier: Modifier.Public)
                {
                    new Enum.Field(@identifier: "One = 1"),
                    new Enum.Field(@identifier: "Two = 2"),
                }
                .WithBase("int");

            var expectet = Comparer.Create_Enum_With_Members_And_Values();
            var actual   = @enum.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }


        public static class Comparer
        {
            public static String Create_Enum()
            {
                return
@"public enum MY_ENUM
{
}";
            }

            public static String Create_Enum_With_Base()
            {
                return
@"public enum MY_ENUM : short
{
}";
            }

            public static String Create_Enum_With_Members()
            {
                return
@"public enum MY_ENUM
{
    One
}";
            }

            public static String Create_Enum_With_Members_And_Values()
            {
                return
@"public enum MY_ENUM : int
{
    One = 1,
    Two = 2
}";
            }
        }
    }
}
